#include "prpsspectrum.h"
#include "private/prpsprpdspectrumprivatedefine.h"
#include "common/dataspecificationutils.h"
#include "common/binaryprocesshelper.h"
#include "common/xmldocument.h"
#include "private/spectrumdatafilecommondefine.h"
#include "common/xmlprocesshelper.h"
#include <QDebug>

namespace DataSpecificationGW
{
    class PRPSSpectrumPrivate
    {
    public:
        PRPSExtInformationPrivate m_stPRPSExtInformationPrivate;
        PRPSDataPrivate m_stPRPSDataPrivate;
    };

    PRPSSpectrum::PRPSSpectrum()
        : Spectrum(),
          m_pPRPSSpectrumPrivate(new PRPSSpectrumPrivate)
    {
    }

    PRPSSpectrum::~PRPSSpectrum()
    {
    }

    /************************************************
     * 函数名   : setDataSpecificationVersion
     * 输入参数 :
       const DataSpecificationVersion eDataSpecificationVersion: 数据规范版本号
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置数据规范版本号
     ************************************************/
    void PRPSSpectrum::setDataSpecificationVersion(const DataSpecificationVersion eDataSpecificationVersion)
    {
        Spectrum::setDataSpecificationVersion(eDataSpecificationVersion);
        if (V_1_1_0_0 == eDataSpecificationVersion)
        {
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipDataJudgmentFlag();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipGain();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipSyncSource();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipSyncState();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipSyncFrequency();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipDischargeSeverity();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipDenoisingThreshold();
        }
        else if (V_4_1_0_2 == eDataSpecificationVersion)
        {
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipBGFileName();
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.skipDenoisingThreshold();
        }
    }

    /************************************************
     * 函数名   : spectrumName
     * 输入参数 : NULL
     * 输出参数 : NULL
     * 返回值   : QString
     * 功能     : 图谱名称
     ************************************************/
    QString PRPSSpectrum::spectrumName() const
    {
        return STR_FILE_NODE_PRPS;
    }

    /************************************************
     * 函数名   : setPRPSExtInformation
     * 输入参数 :
       const PRPSExtInformation& stPRPSExtInformation: PRPSExtInformation
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置PRPSExtInformation
     ************************************************/
    void PRPSSpectrum::setPRPSExtInformation(const PRPSExtInformation& stPRPSExtInformation)
    {
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit = stPRPSExtInformation.eAmpUnit;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit = stPRPSExtInformation.fAmpLowerLimit;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit = stPRPSExtInformation.fAmpUpperLimit;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand = stPRPSExtInformation.eFrequencyBand;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit = stPRPSExtInformation.fFrequencyLowerLimit;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit = stPRPSExtInformation.fFequencyUpperLimit;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount = stPRPSExtInformation.iPhaseWindowCount;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude = stPRPSExtInformation.iQuantizedAmplitude;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount = stPRPSExtInformation.iPowerFreqCycleCount;

        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability.reserve(8);
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability.clear();
        for (const quint8& ucDischargeTypeProb : stPRPSExtInformation.aucPDTypeProbability)
        {
            m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability.push_back(ucDischargeTypeProb);
        }

        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName = stPRPSExtInformation.qstrBGFileName;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag = stPRPSExtInformation.eDataJudgmentFlag;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain = stPRPSExtInformation.sGain;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource = stPRPSExtInformation.eSyncSource;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState = stPRPSExtInformation.ucSyncState;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency = stPRPSExtInformation.fSyncFrequency;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity = stPRPSExtInformation.eDischargeSeverity;
        m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold = stPRPSExtInformation.ucDenoisingThreshold;
    }

    /************************************************
     * 函数名   : setPRPSData
     * 输入参数 :
       const PRPSData& stPRPSData: PRPSData
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置PRPSData
     ************************************************/
    void PRPSSpectrum::setPRPSData(const PRPSData& stPRPSData)
    {
        m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData = stPRPSData.qbaPDSpectrumData;
    }

    /************************************************
     * 函数名   : getPRPSExtInformation
     * 输入参数 : NULL
     * 输出参数 :
       PRPSExtInformation& stPRPSExtInformation: PRPSExtInformation
     * 返回值   : void
     * 功能     : 获取PRPSExtInformation
     ************************************************/
    void PRPSSpectrum::getPRPSExtInformation(PRPSExtInformation& stPRPSExtInformation)
    {
        stPRPSExtInformation.eAmpUnit = static_cast<AmpUnit>(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit);
        stPRPSExtInformation.fAmpLowerLimit = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit;
        stPRPSExtInformation.fAmpUpperLimit = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit;
        stPRPSExtInformation.eFrequencyBand = static_cast<FrequencyBand>(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand);
        stPRPSExtInformation.fFrequencyLowerLimit = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit;
        stPRPSExtInformation.fFequencyUpperLimit = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit;
        stPRPSExtInformation.iPhaseWindowCount = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount;
        stPRPSExtInformation.iQuantizedAmplitude = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude;
        stPRPSExtInformation.iPowerFreqCycleCount = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount;

        std::copy(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability.begin(), m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability.end(), stPRPSExtInformation.aucPDTypeProbability);

        stPRPSExtInformation.qstrBGFileName = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName;
        stPRPSExtInformation.eDataJudgmentFlag = static_cast<DataJudgmentFlag>(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag);
        stPRPSExtInformation.sGain = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain;
        stPRPSExtInformation.eSyncSource = static_cast<SyncSource>(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource);
        stPRPSExtInformation.ucSyncState = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState;
        stPRPSExtInformation.fSyncFrequency = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency;
        stPRPSExtInformation.eDischargeSeverity = static_cast<DischargeSeverity>(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity);
        stPRPSExtInformation.ucDenoisingThreshold = m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold;
    }

    /************************************************
     * 函数名   : getPRPSData
     * 输入参数 : NULL
     * 输出参数 :
       PRPSData& stPRPSData: PRPSData
     * 返回值   : void
     * 功能     : 获取PRPSData
     ************************************************/
    void PRPSSpectrum::getPRPSData(PRPSData& stPRPSData)
    {
        stPRPSData.qbaPDSpectrumData = m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData;
    }

    /************************************************
     * 函数名   : saveBinarySpectrumExtInfo
     * 输入参数 :
       QDataStream& out: 输出流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存二进制可扩展信息段
     ************************************************/
    bool PRPSSpectrum::saveBinarySpectrumExtInfo(QDataStream& out)
    {
        out.device()->seek(SPECTRUM_HEADER_LENGTH);


        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUnit)out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpLowerLimit) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUpperLimit) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyBand) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyLowerLimit) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFequencyUpperLimit) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPhaseWindowCount) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipQuantizedAmplitude) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPowerFreqCycleCount) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount;

        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPDTypePR)
        {
            for (const quint8& uPDType : m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability)
            {
                out << uPDType;
            }
        }

        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipBGFileName) DataSpecificationUtils::convertStringToBinary(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName, TYPE_ASCII, out, BG_FILE_NAME_LENTH);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDataJudgmentFlag) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipGain) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncSource) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncState) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncFrequency) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDischargeSeverity) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity;
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDenoisingThreshold) out << m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold;

        DataSpecificationUtils::saveBinaryReservedData(SPECTRUM_BASE_LENGTH - out.device()->size(), out);

        return true;
    }

    /************************************************
     * 函数名   : saveXMLSpectrumExtInfo
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
       QDomElement& element: dom元素
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存XML可扩展信息段
     ************************************************/
    bool PRPSSpectrum::saveXMLSpectrumExtInfo(XMLDocument& xmlDocumentObj, QDomElement& element)
    {
        xmlDocumentObj.beginElement(element);
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_EXTINFORMATION);

        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUnit) xmlDocumentObj.setValue(TEXT_AMP_UNIT, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpLowerLimit) xmlDocumentObj.setValue(TEXT_AMP_MIN, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit, 'f', 1));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUpperLimit) xmlDocumentObj.setValue(TEXT_AMP_MAX, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit, 'f', 1));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyBand) xmlDocumentObj.setValue(TEXT_BAND_WIDTH, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyLowerLimit) xmlDocumentObj.setValue(TEXT_FRQ_MIN, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit, 'f', 1));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFequencyUpperLimit) xmlDocumentObj.setValue(TEXT_FRQ_MAX, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit, 'f', 1));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPhaseWindowCount) xmlDocumentObj.setValue(TEXT_PHASE_INTVL_COUNT, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipQuantizedAmplitude) xmlDocumentObj.setValue(TEXT_QUANTY_AMP, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPowerFreqCycleCount) xmlDocumentObj.setValue(TEXT_PFRECYCLE_COUNT, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPDTypePR) xmlDocumentObj.setValue(TEXT_PD_TYPE_PR, DataSpecificationUtils::dischargeTypeProbabilityVector2QString(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipBGFileName) xmlDocumentObj.setValue(TEXT_BG_FILE_NAME, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDataJudgmentFlag) xmlDocumentObj.setValue(TEXT_EFFECIVE_SIGN, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipGain) xmlDocumentObj.setValue(TEXT_GAIN, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncSource) xmlDocumentObj.setValue(TEXT_SYNC_SOURCE, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncState) xmlDocumentObj.setValue(TEXT_SYNC_STATE, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncFrequency) xmlDocumentObj.setValue(TEXT_SYNC_FREQ, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency, 'f', 1));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDischargeSeverity) xmlDocumentObj.setValue(TEXT_DISCHARGE_SEVERITY, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity));
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDenoisingThreshold) xmlDocumentObj.setValue(TEXT_DENOISING_THRESHOLD, QString::number(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold));

        return true;
    }

    /************************************************
     * 函数名   : saveJSONSpectrumExtInfo
     * 输入参数 :
       rapidjson::Document::AllocatorType& alloc:
       rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存JSON可扩展信息段
     ************************************************/
    bool PRPSSpectrum::saveJSONSpectrumExtInfo(rapidjson::Document::AllocatorType& alloc, rapidjson::Value& jsonValue)
    {
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUnit)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit, TEXT_AMP_UNIT, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpLowerLimit)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit, TEXT_AMP_MIN, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUpperLimit)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit, TEXT_AMP_MAX, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyBand)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand, TEXT_BAND_WIDTH, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyLowerLimit)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit, TEXT_FRQ_MIN, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFequencyUpperLimit)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit, TEXT_FRQ_MAX, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPhaseWindowCount)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount, TEXT_PHASE_INTVL_COUNT, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipQuantizedAmplitude)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude, TEXT_QUANTY_AMP, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPowerFreqCycleCount)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount, TEXT_PFRECYCLE_COUNT, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPDTypePR)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability, TEXT_PD_TYPE_PR, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipBGFileName)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName, TEXT_BG_FILE_NAME, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDataJudgmentFlag)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag, TEXT_EFFECIVE_SIGN, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipGain)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain, TEXT_GAIN, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncSource)
            saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource, TEXT_SYNC_SOURCE, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncState) saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState, TEXT_SYNC_STATE, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncFrequency) saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency, TEXT_SYNC_FREQ, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDischargeSeverity) saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity, TEXT_DISCHARGE_SEVERITY, alloc, jsonValue);
        if (!m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDenoisingThreshold) saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold, TEXT_DENOISING_THRESHOLD, alloc, jsonValue);

        return true;
    }

    /************************************************
     * 函数名   : saveBinarySpectrumData
     * 输入参数 :
       QDataStream& out: 输出流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存二进制图谱数据段
     ************************************************/
    bool PRPSSpectrum::saveBinarySpectrumData(QDataStream& out)
    {
        if(dataCount() <= 0)
        {
            return false;
        }

        out.device()->seek(SPECTRUM_BASE_LENGTH);

        DataSpecificationUtils::saveBinaryPointerData(out, storageDataType(), m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData.data(), dataCount());

        return true;
    }

    /************************************************
     * 函数名   : saveXMLSpectrumData
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
       QDomElement& element: dom元素
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存XML图谱数据段
     ************************************************/
    bool PRPSSpectrum::saveXMLSpectrumData(XMLDocument& xmlDocumentObj, QDomElement& element)
    {
        xmlDocumentObj.beginElement(element);
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_DATA);

        QString strData = m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData.toBase64();
        xmlDocumentObj.setValue( STR_SPECTRUM_NODE_DATA, strData );

        return true;
    }

    /************************************************
     * 函数名   : saveJSONSpectrumData
     * 输入参数 :
       rapidjson::Document::AllocatorType& alloc:
       rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存JSON图谱数据段
     ************************************************/
    bool PRPSSpectrum::saveJSONSpectrumData(rapidjson::Document::AllocatorType& alloc, rapidjson::Value& jsonValue)
    {
        if (!m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.bSkipPDSpectrumData) saveJSONField(m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData, STR_SPECTRUM_NODE_DATA, alloc, jsonValue);
        return true;
    }

    /************************************************
     * 函数名   : parseBinarySpectrumExtInfo
     * 输入参数 :
       QDataStream& in: 输入流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析二进制可扩展信息段
     ************************************************/
    bool PRPSSpectrum::parseBinarySpectrumExtInfo(QDataStream& in)
    {
        if (!in.device()->seek(SPECTRUM_HEADER_LENGTH))
        {
            qDebug() << "PRPSSpectrum::parseBinarySpectrumExtInfo failed";
            return false;
        }

        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUnit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpUnit);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpLowerLimit);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipAmpUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpUpperLimit);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyBand, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFrequencyBand);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFrequencyLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFrequencyLowerLimit);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipFequencyUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFequencyUpperLimit);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPhaseWindowCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPhaseWindowCount);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipQuantizedAmplitude, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasQuantizedAmplitude);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPowerFreqCycleCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPowerFreqCycleCount);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipPDTypePR, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability, 8, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPDTypeProbability);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipBGFileName, DataSpecificationGW::TYPE_ASCII, DataSpecificationGW::BG_FILE_NAME_LENTH, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasBGFileName);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDataJudgmentFlag, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDataJudgmentFlag);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipGain, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasgain);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncSource, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncSource);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncState, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncState);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipSyncFrequency, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncFrequency);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDischargeSeverity, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDischargeSeverity);
        parseBinaryField(in, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bSkipDenoisingThreshold, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDenoisingThreshold);

        return in.status() == QDataStream::Ok;
    }

    /************************************************
     * 函数名   : parseXMLSpectrumExtInfo
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析XML可扩展信息段
     ************************************************/
    bool PRPSSpectrum::parseXMLSpectrumExtInfo(XMLDocument& xmlDocumentObj)
    {
        xmlDocumentObj.beginElement(spectrumName());
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_EXTINFORMATION);

        parseXMLField(xmlDocumentObj, TEXT_AMP_UNIT, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpUnit);
        parseXMLField(xmlDocumentObj, TEXT_AMP_MIN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpLowerLimit);
        parseXMLField(xmlDocumentObj, TEXT_AMP_MAX, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpUpperLimit);
        parseXMLField(xmlDocumentObj, TEXT_BAND_WIDTH, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFrequencyBand);
        parseXMLField(xmlDocumentObj, TEXT_FRQ_MIN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFrequencyLowerLimit);
        parseXMLField(xmlDocumentObj, TEXT_FRQ_MAX, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFequencyUpperLimit);
        parseXMLField(xmlDocumentObj, TEXT_PHASE_INTVL_COUNT, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPhaseWindowCount);
        parseXMLField(xmlDocumentObj, TEXT_QUANTY_AMP, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasQuantizedAmplitude);
        parseXMLField(xmlDocumentObj, TEXT_PFRECYCLE_COUNT, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPowerFreqCycleCount);
        parseXMLField(xmlDocumentObj, TEXT_PD_TYPE_PR, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPDTypeProbability);
        parseXMLField(xmlDocumentObj, TEXT_BG_FILE_NAME, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasBGFileName);
        parseXMLField(xmlDocumentObj, TEXT_EFFECIVE_SIGN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDataJudgmentFlag);
        parseXMLField(xmlDocumentObj, TEXT_GAIN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasgain);
        parseXMLField(xmlDocumentObj, TEXT_SYNC_SOURCE, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncSource);
        parseXMLField(xmlDocumentObj, TEXT_SYNC_STATE, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncState);
        parseXMLField(xmlDocumentObj, TEXT_SYNC_FREQ, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncFrequency);
        parseXMLField(xmlDocumentObj, TEXT_DISCHARGE_SEVERITY, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDischargeSeverity);
        parseXMLField(xmlDocumentObj, TEXT_DENOISING_THRESHOLD, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDenoisingThreshold);

        xmlDocumentObj.endElement();
        xmlDocumentObj.endElement();

        return true;
    }

    /************************************************
     * 函数名   : parseJSONSpectrumExtInfo
     * 输入参数 :
       const rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析JSON可扩展信息段
     ************************************************/
    bool PRPSSpectrum::parseJSONSpectrumExtInfo(const rapidjson::Value& jsonValue)
    {
        parseJSONField(jsonValue, TEXT_AMP_UNIT, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucAmpUnit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpUnit);
        parseJSONField(jsonValue, TEXT_AMP_MIN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpLowerLimit);
        parseJSONField(jsonValue, TEXT_AMP_MAX, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fAmpUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasAmpUpperLimit);
        parseJSONField(jsonValue, TEXT_BAND_WIDTH, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucFrequencyBand, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFrequencyBand);
        parseJSONField(jsonValue, TEXT_FRQ_MIN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFrequencyLowerLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFrequencyLowerLimit);
        parseJSONField(jsonValue, TEXT_FRQ_MAX, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fFequencyUpperLimit, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasFequencyUpperLimit);
        parseJSONField(jsonValue, TEXT_PHASE_INTVL_COUNT, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPhaseWindowCount);
        parseJSONField(jsonValue, TEXT_QUANTY_AMP, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iQuantizedAmplitude, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasQuantizedAmplitude);
        parseJSONField(jsonValue, TEXT_PFRECYCLE_COUNT, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPowerFreqCycleCount);
        parseJSONField(jsonValue, TEXT_PD_TYPE_PR, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.vecPDTypeProbability, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasPDTypeProbability);
        parseJSONField(jsonValue, TEXT_BG_FILE_NAME, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.qstrBGFileName, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasBGFileName);
        parseJSONField(jsonValue, TEXT_EFFECIVE_SIGN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDataJudgmentFlag, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDataJudgmentFlag);
        parseJSONField(jsonValue, TEXT_GAIN, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.sGain, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasgain);
        parseJSONField(jsonValue, TEXT_SYNC_SOURCE, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncSource, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncSource);
        parseJSONField(jsonValue, TEXT_SYNC_STATE, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucSyncState, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncState);
        parseJSONField(jsonValue, TEXT_SYNC_FREQ, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.fSyncFrequency, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasSyncFrequency);
        parseJSONField(jsonValue, TEXT_DISCHARGE_SEVERITY, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDischargeSeverity, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDischargeSeverity);
        parseJSONField(jsonValue, TEXT_DENOISING_THRESHOLD, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.ucDenoisingThreshold, m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.bHasDenoisingThreshold);

        return true;
    }

    /************************************************
     * 函数名   : parseBinarySpectrumData
     * 输入参数 :
       QDataStream& in: 输入流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析二进制图谱数据段
     ************************************************/
    bool PRPSSpectrum::parseBinarySpectrumData(QDataStream& in)
    {
        if (!in.device()->seek(SPECTRUM_BASE_LENGTH))
        {
            qDebug() << "PRPSSpectrum::parseBinarySpectrumData failed";
            return false;
        }

        DataSpecificationUtils::parseBinaryPointerData(in, storageDataType(), m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData, dataCount());

        return in.status() == QDataStream::Ok;
    }

    /************************************************
     * 函数名   : parseXMLSpectrumData
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析XML图谱数据段
     ************************************************/
    bool PRPSSpectrum::parseXMLSpectrumData(XMLDocument& xmlDocumentObj)
    {
        xmlDocumentObj.beginElement(spectrumName());
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_DATA);

        m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData = QByteArray::fromBase64(xmlDocumentObj.value(STR_SPECTRUM_NODE_DATA).toLatin1());

        xmlDocumentObj.endElement();
        xmlDocumentObj.endElement();

        return true;
    }

    /************************************************
     * 函数名   : parseJSONSpectrumData
     * 输入参数 :
       const rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析JSON图谱数据段
     ************************************************/
    bool PRPSSpectrum::parseJSONSpectrumData(const rapidjson::Value& jsonValue)
    {
        parseJSONField(jsonValue, STR_SPECTRUM_NODE_DATA, m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.qbaPDSpectrumData, m_pPRPSSpectrumPrivate->m_stPRPSDataPrivate.bHasPDSpectrumData);

        return true;
    }

    int PRPSSpectrum::dataCount()
    {
        return m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPhaseWindowCount * m_pPRPSSpectrumPrivate->m_stPRPSExtInformationPrivate.iPowerFreqCycleCount;
    }
}
